<template>
    <el-row>
        <el-col :span="24">
          <Portlet title="账号信息">
            <el-form class="el-form-col el-form-s" label-position="left" label-width="150px">
              <el-row>
                <el-col :span="6">
                  <el-form-item label="姓名：">
                    <span>{{userData.name}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="岗位：">
                    <span>{{ userData.position }}</span>
                  </el-form-item>
                </el-col>
                <el-col v-if="credentialDetail.isCredential" :span="24">
                  <el-form-item label="公司名称：">
                    <span>{{ credentialDetail.companyName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="登录账号：">
                    <span>{{userData.phone || userData.loginName}}</span>
                  </el-form-item>
                </el-col>
                <!--<el-col :span="2">
                  <el-form-item>
                    <el-button type="text" @click.prevent="showChangePhone(userData.phone)">更换手机</el-button>
                  </el-form-item>
                </el-col>-->
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="登录密码：">
                    <span>＊＊＊＊＊＊＊</span>
                  </el-form-item>
                </el-col>
                <el-col :span="2">
                  <el-form-item>
                    <el-button type="text" @click.prevent.stop="goChangePsw(userData)">修改</el-button>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </Portlet>
        </el-col>
    </el-row>
</template>
<script>
import {dotData} from '@/utils'
import {getUserInfo} from '@/utils/auth'
export default {
  name: 'myAccountIndex',
  components: {
  },
  data() {
    return {
      userData: {},
      credentialDetail: {}
    }
  },
  created() {
    this.getUser()
    this.isPassCompanyAuthentication()
  },
  methods: {
    getUser() {
      this.$ajax.get('/ms-common-user/user/get-user').then(response => {
        if (response.success) {
          this.userData = dotData(response, 'data')
        }
      })
    },
    // 改绑手机
    showChangePhone(thisPhone) {
      this.$router.push({path: '/redirect/ss-fhb/myAccount/change-phone/' + thisPhone})
    },
    // 修改密码
    goChangePsw(data) {
      this.$router.push({
        path: '/redirect/ss-fhb/myAccount/changePsw/' + data.id,
        query: {phone: data.phone, loginName: data.loginName}
      })
    },
    // 获取发货宝是否通过公司认证
    isPassCompanyAuthentication() {
      this.$ajax.get('/ms-fahuobao-user/OutGoodsUser/is-mentCredential', {userId: getUserInfo('id')}).then(response => {
        if (response.success) {
          this.credentialDetail = response.data || {}
        }
      })
    }
  }
}
</script>
